<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card class="box-card">
      <!-- 搜索 -->
      <el-form ref="SerachformRef" label-width="80px">
        <!-- 输入框 -->
        <el-input v-model="queryInfo.query" placeholder="请输入内容" style="width:250px"></el-input>
        <!-- 按钮 -->
        <el-button @click="getOrderList">
          <i class="el-icon-search"></i>
        </el-button>
      </el-form>

      <!-- 表格的组件 -->
      <el-table :data="orderList" stripe border style="width: 100%">
        <el-table-column type="index" width="50"></el-table-column>
        <el-table-column prop="order_number" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格" width="150"></el-table-column>
        <el-table-column prop="pay_status" label="是否付款" width="150">
          <template slot-scope="scoped">
            <el-tag v-if="scoped.row.pay_status==='1'">已付款</el-tag>
            <el-tag v-else type="danger">未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货" width="150"></el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <template slot-scope="scoped">{{scoped.row.create_time|dataFormat}}</template>
        </el-table-column>
        <el-table-column label="操作">
          <el-button type="primary" icon="el-icon-edit" size="mini" title="修改订单地址"></el-button>
          <el-button
            type="success"
            class="el-icon-location-outline"
            size="mini"
            title="物流信息"
            @click="showDilog"
          ></el-button>
        </el-table-column>
      </el-table>

      <!-- 分页插件 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[5, 8, 10, 20]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>

      <!-- 展示物流信息的对护框 -->
      <el-dialog title="查看物流进度" :visible.sync="dialogVisible" width="50%">
        <el-steps direction="vertical" :active="1">
          <el-step :title="item.time" v-for="(item,i) in wLinfo" :key="i" :description="item.context"></el-step>
        </el-steps>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary">确 定</el-button>
        </span>
      </el-dialog>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //   订单列表
      orderList: [],
      //   参数对象
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10
      },
      //   总页数
      total: 0,
      dialogVisible: false,
      wLinfo: []
    };
  },
  methods: {
    // 获取订单列表
    async getOrderList() {
      const { data: res } = await this.$http.get(`orders`, {
        params: this.queryInfo
      });
      if (res.meta.status !== 200) {
        return this.$message.error("获取订单列表失败");
      }
      //   console.log(res);
      this.total = res.data.total;
      this.orderList = res.data.goods;
    },
    // 一页有多少条数据
    handleSizeChange(size) {
      console.log(size);
      this.queryInfo.pagesize = size;
      this.getOrderList();
    },
    // 页码
    handleCurrentChange(num) {
      this.queryInfo.pagenum = num;
      this.getOrderList();
    },
    // 查看物流进度
    async showDilog() {
      this.dialogVisible = !this.dialogVisible;
      const { data: res } = await this.$http.get("kuaidi/1106975712662");
      console.log(res);
      if (res.meta.status !== 200) {
        return this.$message.error("查询物流进度失败");
      }
      this.wLinfo = res.data;
    },
    // 搜索部分
    serach(){
      
    }
  },
  created() {
    this.getOrderList();
  }
};
</script>

<style lang="less" scoped>
.el-card {
  margin-top: 20px;
}
.el-table {
  margin-top: 15px;
}
</style>

